<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */
use Hyperf\Database\Migrations\Migration;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Schema\Schema;

class UpdateA04ConfigTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('strategy_config', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id')->index()->comment('用户id');
            $table->string('symbol', 30)->comment('交易品种，如 NXP_USDT');
            $table->string('version', 10)->default('7.0');
            $table->decimal('leverage', 5, 2)->default(0)->comment('持仓杠杆');
            $table->decimal('open_distance', 10, 6)->default(0)->comment('开仓距离');
            $table->decimal('close_distance', 10, 6)->default(0)->comment('平仓距离');
            $table->string('reference_market', 30)->nullable(true)->comment('参考盘口');
            $table->tinyInteger('enable_stop')->default(0)->comment('是否启用止币');
            $table->decimal('max_drawdown', 5, 2)->nullable(true)->comment('回撤止损 %');
            $table->integer('order_rate')->default(0)->comment('下单速率 /s');
            $table->tinyInteger('enable_realtime')->default(0);
            $table->tinyInteger('enable_save_ticker')->default(0);
            $table->tinyInteger('enable_log')->default(0);
            $table->tinyInteger('enable_colo')->default(0);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('strategy_config', function (Blueprint $table) {});
    }
}
